package engine.scene;

public class SoundSourceBuffer
{
    
    private static final int MAX_SOUND_SOURCES = 50;
    
    
    private int numSoundSourcesSent;
    //<editor-fold defaultstate="collapsed" desc="getNumSoundSources">
    public int getNumSoundSources()
    {
        return this.numSoundSourcesSent;
    }
        //</editor-fold>
    
    private SoundSource[] soundSources;
    
    public SoundSourceBuffer()
    {
        this.soundSources = new SoundSource[SoundSourceBuffer.MAX_SOUND_SOURCES];
        this.resetIndices();
    }
    
    public void addSoundSource(SoundSource soundSource)
    {
        if (soundSource != null)
        {
            this.soundSources[this.numSoundSourcesSent++] = soundSource;
        }
    }
    
    public SoundSource getSoundSourceAt(int index)
    {
        return this.soundSources[index];
    }
    
    public void nullifySoundSourceAt(int index)
    {
        this.soundSources[index] = null;
    }
    
    public void clearSoundSources()
    {
        for (int i = 0; i < this.numSoundSourcesSent; i++)
        {
            this.nullifySoundSourceAt(i);
        }
        this.resetIndices();
    }
    
    public final void resetIndices()
    {
        this.numSoundSourcesSent = 0;
    }
    
    public void destroy()
    {
        this.resetIndices();
        this.soundSources = null;
    }
    
}
